#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <deque>
#include <map>
using namespace std;
const int maxn = 1e5 + 7, maxL = 1e6 + 7;
int T, n, m, L, V, ans, cnt;
bool no_change_speed;
bool vis[maxn];
struct car{
    int d, v, a;
    int l, r;
    bool ism;
}c[maxn];
int p[maxn];
void subtask1(){
    int farther = -1;
    for(int i = 1; i <= n; i++)
        if(c[i].d <= p[m] && c[i].v > V){
            farther = max(farther, c[i].d);
            cnt++;
        }
    if(farther == -1) ans = m;
    else ans = m - 1;
    printf("%d %d\n", cnt, ans);
    return;
}
bool find_p(int a, int b){
    int l = 1, r = m, mid;
    while(l <= r){
        mid = (l + r) / 2;
        if(p[mid] >= a && p[mid] <= b) return true;
        else if(p[mid] < a) l = mid + 1;
        else r = mid - 1;
    }
    return false;
}
bool cmp(car x, car y){
    return x.l < y.l;
}
void force(){
    for(int i = 1; i <= n; i++){
        c[i].ism = false;
        int a = c[i].a, v = c[i].v, d = c[i].d;
        if(a == 0){
            if(v > V){
                c[i].l = d;
                c[i].r = L;
                if(d <= p[m]) cnt++, c[i].ism = true;
            }
        }
        else if(a > 0){
            if(v > V){

                c[i].l = d;
                c[i].r = L;
                if(d <= p[m]) cnt++, c[i].ism = true;
            }
            else{
                double t = (V - v) * 1.0 / a * 1.0;
                double s = 1.0 * v * t + 0.5 * a * t * t;
                double pos = d * 1.0 + s;
                int before = pos, after = pos;
                if(double(pos - double(before * 1.0)) > 0.0) after ++;
                if(after <= p[m]){
                    cnt++;
                    c[i].l = after;
                    c[i].r = L;
                    c[i].ism = true;
                }
            }
        }
        else{
            if(v > V){
                double t = (V - v) * 1.0 / a * 1.0;
                double s = 1.0 * v * t + 0.5 * a * t * t;
                double pos = d * 1.0 + s;
                int before = pos, after = pos;
                if(double(pos - double(before * 1.0)) > 0.0) after ++;
                if(find_p(d, before)) cnt++, c[i].ism = true;
                c[i].l = d;
                c[i].r = before;
            }
        }
    }
    sort(c+1, c+n+1, cmp);
    int sum = 1, it = 1;
    bool noc = true;
    while(1){
        for(int i = it + 1; i <= n; i++){
            if(!c[i].ism) continue;
            noc = false;
            if(c[i].l > c[it].r || c[i].r < c[it].l){
                if(it <= n){
                    sum++;
                    it = i;
                }
                break;
            }
        }
        break;
        if(it > n) break;
    }
    if(noc){
        printf("%d %d\n", cnt, m);
        return;
    }
    ans = m - sum;
    printf("%d %d\n", cnt, ans);
    return;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while(T--){
        scanf("%d%d%d%d", &n, &m, &L, &V);
        no_change_speed = true;
        for(int i = 1; i <= n; i++){
            scanf("%d%d%d", &c[i].d, &c[i].v, &c[i].a);
            if(c[i].a != 0) no_change_speed = false;
        }
        ans = 0, cnt = 0;
        for(int i = 1; i <= m; i++) scanf("%d", &p[i]);
        if(no_change_speed) subtask1();
        else force();
    }
    return 0;
}
